home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 145
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin
/
games
/
spassion
/
source.lzh
/
SOURCE
/
ESHOT.C
< prev
next >
Wrap
Text File
|
2000-03-31
|
24KB
|
916 lines
/*
#include <stdio.H>
#include <iocslib.H>
*/
#include <XSP2lib.H>
#include "SPASSION.H"
#include "PLAYER.H"
#include "ENEMY.H"
#include "ESHOT.H"
#include "PRIORITY.H"
#include "BG.H"
#include "SOUND.H"
#include "SUB.H"
#ifndef NULL
#define NULL ((void *) 0)
#endif
#define X_MIN (16)
#define X_MAX (16+256)
#define Y_MIN (16)
#define Y_MAX (16+256)
#define SWAP(x,y) ((x)^=(y)^=(x)^=(y))
#define ESHOT_MAX 200
static ESHOT eshot[ ESHOT_MAX ];
static ESHOT *eshot_free = 0,
*eshot_top = 0;
static void InitEShotEng01( ESHOT * );
static void InitEShotEng02( ESHOT * );
static void InitEShotEng03( ESHOT * );
static void InitEShotNomal( ESHOT * );
static void InitEShotSyuriken( ESHOT * );
static void InitEShotEnergy01( ESHOT * );
static void InitEShotEnergy02( ESHOT * );
static void InitEShotEnergy03( ESHOT * );
static void InitEShotRing01( ESHOT * );
static void InitEShotRing02( ESHOT * );
static void InitEShotLaser00( ESHOT * );
static void InitEShotCutter( ESHOT * );
static void InitEShotHoming( ESHOT * );
static void InitEShotParachute( ESHOT * );
static void InitEShotParabola( ESHOT * );
static void InitEShotLaser01( ESHOT * );
static void InitEShotLaserEX( ESHOT * );
static short MoveShot1( ESHOT * );
static short MoveShot2( ESHOT * );
static short MoveShot3( ESHOT * );
static short MoveShot4( ESHOT * );
static short MoveShot5( ESHOT * );
static short MoveShot6( ESHOT * );
static short MoveShot7( ESHOT * );
static short eng1_pt[]={0x34,-1};
static short eng2_pt[]={0x35,-1};
static short eng3_pt[]={0x36,-1};
static short nomal_pt[] ={0x37,-1};
static short syuriken_pt[]={0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,-1};
static short energy1_pt[]={0x28,0x29,0x2A,0x2B,-1};
static short energy2_pt[]={0x2C,0x2D,0x2E,0x2F,-1};
static short ring1_pt[]={0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,-1};
static short ring2_pt[]={0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,-1};
static short homing_pt[] ={0x47,-1};
static short laser00_pt[] ={0x59,-1};
static short cutter_pt[] ={0x62,-1};
static short energy3_pt[] ={0x6B,0x6C,0x6D,0x6E,-1};
static short parachute_pt[]={0x70,-1};
static short parabola_pt[]={0x6F,-1};
static HIT_XY eng1_p_hit[2]={2,2,-1,-1},eng1_o_hit[2];
static HIT_XY eng2_p_hit[2]={4,4,-1,-1},eng2_o_hit[2];
static HIT_XY eng3_p_hit[2]={8,8,-1,-1},eng3_o_hit[2];
static HIT_XY nomal_p_hit[10]={1,4, 1,3, 1,3, 1,3, 2,2, 2,2, 3,1, 3,1, 4,1,-1,-1},nomal_o_hit[10];
static HIT_XY syuriken_p_hit[2]={4,4,-1,-1},syuriken_o_hit[2];
static HIT_XY energy1_p_hit[2]={4,4,-1,-1},energy1_o_hit[2];
static HIT_XY energy2_p_hit[5]={4,4,3,5,4,4,5,3,-1,-1},energy2_o_hit[5];
static HIT_XY ring1_p_hit[2]={5,5,-1,-1},ring1_o_hit[2];
static HIT_XY ring2_p_hit[2]={7,7,-1,-1},ring2_o_hit[2];
static HIT_XY homing_p_hit[10]={1,4, 1,3, 1,3, 1,3, 2,2, 2,2, 3,1, 3,1, 4,1 ,-1,-1},homing_o_hit[10];
static HIT_XY laser00_p_hit[10]={2,8,3,7,3,6,4,6,5,5,6,4,6,4,7,3,8,2,-1,-1},laser00_o_hit[10];
static HIT_XY cutter_p_hit[10]={4,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,4,-1,-1},cutter_o_hit[10];
static HIT_XY energy3_p_hit[5]={4,7,5,5,7,4,5,5,-1,-1},energy3_o_hit[5];
static HIT_XY parachute_p_hit[2]={2,2,-1,-1},parachute_o_hit[2];
static HIT_XY parabola_p_hit[2]={8,8,-1,-1},parabola_o_hit[2];
static HIT_XY laser01_p_hit[1],laser01_o_hit[1];
static HIT_XY laserex_p_hit[1],laserex_o_hit[1];
short *pt[]={
eng1_pt,
eng2_pt,
eng3_pt,
nomal_pt,
syuriken_pt,
energy1_pt,
energy2_pt,
energy3_pt,
ring1_pt,
ring2_pt,
laser00_pt,
cutter_pt,
homing_pt,
parachute_pt,
parabola_pt,
NULL
};
HIT_XY *hit_p[]={
eng1_p_hit,
eng2_p_hit,
eng3_p_hit,
nomal_p_hit,
syuriken_p_hit,
energy1_p_hit,
energy2_p_hit,
energy3_p_hit,
ring1_p_hit,
ring2_p_hit,
laser00_p_hit,
cutter_p_hit,
homing_p_hit,
parachute_p_hit,
parabola_p_hit
};
HIT_XY *hit_o[]={
eng1_o_hit,
eng2_o_hit,
eng3_o_hit,
nomal_o_hit,
syuriken_o_hit,
energy1_o_hit,
energy2_o_hit,
energy3_o_hit,
ring1_o_hit,
ring2_o_hit,
laser00_o_hit,
cutter_o_hit,
homing_o_hit,
parachute_o_hit,
parabola_o_hit
};
typedef void (*func_init) (struct ESHOT *);
func_init FuncEShotInit[]=
{
InitEShotEng01,
InitEShotEng02,
InitEShotEng03,
InitEShotNomal,
InitEShotSyuriken,
InitEShotEnergy01,
InitEShotEnergy02,
InitEShotEnergy03,
InitEShotRing01,
InitEShotRing02,
InitEShotLaser00,
InitEShotCutter,
InitEShotHoming,
InitEShotParachute,
InitEShotParabola,
InitEShotLaser01,
InitEShotLaserEX,
};
/* ゲーム開始時に呼ばれる */
void InitEShot0( void )
{
short i,j;
for( i=0;pt[i]!=NULL;i++ ){
for( j=0;pt[i][j]!=-1;j++ ){
pt[i][j]+=obj_shot;
}
for( j=0;hit_p[i][j].x!=-1;j++ ){
hit_o[i][j].x=hit_p[i][j].x+OPTION_HIT_X;
hit_o[i][j].y=hit_p[i][j].y+OPTION_HIT_Y;
/* hit_p[i][j].x+=PLAYER_HIT_X;
hit_p[i][j].y+=PLAYER_HIT_Y;
*/
}
}
}
void InitEShot( void )
{
short i;
eshot_top = NULL;
eshot_free = eshot;
for( i = 0 ; i < ESHOT_MAX; i++ )
eshot[i].next = &eshot[i + 1];
eshot[ ESHOT_MAX - 1 ].next = NULL;
eshot_erase = 0;
}
/*
* 敵弾発生
*/
ESHOT *MakeEShot(short type, signed short x, signed short y,
unsigned char speed, unsigned char angle, signed short t,
short arg, ENEMY *enemy)
{
ESHOT *eshot;
/* 空いているか調べる */
if ( !eshot_free ) return NULL;
/* 空いているのを探す */
eshot = eshot_free;
eshot_free = eshot->next;
/* 使っているリストに入れる */
eshot->next = eshot_top;
eshot_top = eshot;
/* 各種設定 */
eshot->lx = x<<16;
eshot->ly = y<<16;
eshot->vx = vx_tbl[speed][angle];
eshot->vy = vy_tbl[speed][angle];
eshot->pt = nomal_pt[0]+pt_rot[angle];
eshot->type = type;
eshot->arg = arg;
eshot->state = 0;
eshot->angle = angle;
eshot->speed = speed;
eshot->flg = 0;
eshot->anim_count = 0;
eshot->count = 0;
eshot->enemy = enemy;
FuncEShotInit[type](eshot); /* 初期化ルーチンへ飛ぶ(関数へのポインタってヤツ) */
return eshot;
}
/*
* 敵弾の移動
*/
void MoveEShot( void )
{
PLAYER *pl;
ESHOT *eshot,*q;
signed short pl_x, pl_y;
signed short eshot_x, eshot_y;
eshot = eshot_top; /* 現在注目しているワーク */
q = NULL; /* 1つ前のワーク(ワーク削除時に必要) */
/* 弾消し中か?(高速化のためやや冗長なコードになってます) */
if( !eshot_erase ){
/* 通常の処理(弾消しではない) */
while( eshot ){
short erase_flag=0;
#if 0
if ( !eshot->func_eshot_move ){ /* 敵弾の移動ルーチンがない? */
void game_end();
game_end();
}
#endif
if ( !( *( eshot->func_eshot_move ) )( eshot ) ) { /* 弾を移動させる */
erase_flag=1;
} else { /* 消滅していない時 */
/* 敵弾と自機の当たり判定 */
signed short t, hx = eshot->hit_o->x,hy = eshot->hit_o->y,i,j;
eshot_x = ESHOT_X;
eshot_y = ESHOT_Y;
for( i=0,pl=&player[0];i<=play_mode;i++,pl++ ){
/* オプションとの当たり判定 */
for( j=0;j<2;j++ ){
signed short shot_w;
if( (t = ESHOT_X + hx) >= (shot_w = *((short *) (&pl->option[j].lx))) ){
if( (t -= (short) (hx << 1)) <= shot_w ){
if( (t = ESHOT_Y + hy) >= (shot_w = *((short *) (&pl->option[j].ly))) ){
if( (t -= (short) (hy << 1)) <= shot_w ){
#if 0
printf("OPTION_HIT!! \n");
printf("j=%d op_x=%d \n",j,pl->option[j].lx>>16);
printf("esx=%d esy=%d \n",eshot_x,eshot_y);
printf("esx1=%d esx2=%d \n",eshot_x - eshot->hit_ox,eshot_x + eshot->hit_ox);
xsp_out();
key_wait();
#endif
/* if( !eshot->laser )*/
if( eshot->type<ESHOT_LASER01 )
erase_flag=1;
}
}
}
}
if( erase_flag )
break;
}
if( erase_flag )
break;
/* プレイヤーとの当たり判定 */
pl_x = player->x + 5;pl_y = pl->y;
hx=eshot->hit_p->x;
hy=eshot->hit_p->y;
if( (t = eshot_x - hx) <= pl_x ){
if( (t += (short) (hx << 1)) >= pl_x ){
if( (t = eshot_y + hy) >= pl_y ){
if( (t -= (short) (hy << 1)) <= pl_y ){
#if 1
if( player->state == PLAYER_ALIVE ){
if( !player->muteki_count )
pl->state = PLAYER_DEAD; /* プレイヤー撃破 */
}
#endif
#if 0
printf("PLAYER_HIT!! \n");
printf("i=%d p_x=%d px=%d py=%d \n",i,player->x,player->x+6,player->y);
printf("es_x=%d es_x1=%d es_x2=%d \n",eshot_x,eshot_x - hx,eshot_x + hx);
printf("es_y=%d es_y1=%d es_y2=%d \n",eshot_y,eshot_y - hy,eshot_y + hy);
xsp_out();
key_wait();
#endif
/* if( !eshot->laser )*/
if( eshot->type<ESHOT_LASER01 )
erase_flag=1;
}
}
}
}
if( erase_flag )
break;
}
}
if( erase_flag ){
if (q == NULL) { /* リストの一番最初を削除 */
eshot_top = eshot->next;
eshot->next = eshot_free;
eshot_free = eshot;
q = NULL;
eshot = eshot_top;
} else {
q->next = eshot->next;
eshot->next = eshot_free;
eshot_free = eshot;
eshot = q->next;
}
}else{
q = eshot;
eshot = eshot->next;
}
}
}else{
/* 弾消し中 */
char erase_flag;/* キャラクターを消す場合 =!0 */
unsigned short erase_table[14] =
{0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B};
while( eshot ){
signed short p_x, p_y;
if (eshot_erase > 1)
erase_flag = 0;
else
erase_flag = !0; /* 最後までアニメーションしたら消す */
#ifdef DEBUG
eshot_sum++;
#endif
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p_x = eshot->x = ((eshot->lx += eshot->vx) >> 16)-8; /*-8は表示位置をずらすため*/
p_y = eshot->y = ((eshot->ly += eshot->vy) >> 16)-8;
/* 敵弾が画面外に出たか? */
/* (画面右から出た判定と左から出た判定を1回の比較で行っている) */
/* (unsigned short)に型変換することで256+16オーバーにしてるんですね、すごいっす */
if (((unsigned short) p_x > 256 + 16) || ((unsigned short) p_y > 256 + 16)) {
/* if( eshot->type<ESHOT_LASER01 )*/
erase_flag = !0;
} else {
if( eshot->type<ESHOT_LASER01 ){
eshot->pt = obj_obj + erase_table[eshot_erase];
eshot->info = 0x0430;
xsp_set_st(eshot);
}
}
if( erase_flag ){
/* if( eshot->laser ){*/
if( eshot->type>=ESHOT_LASER01 ){
extern BOX_PTR *old_box_buf[32];
extern short old_box_num;
eshot->box.color=0;
old_box_buf[old_box_num++]=&eshot->box;
old_box_num&=31;
old_box_buf[old_box_num]=(BOX_PTR *)0;
}
if (q == NULL) { /* リストの一番最初を削除 */
eshot_top = eshot->next;
eshot->next = eshot_free;
eshot_free = eshot;
q = NULL;
eshot = eshot_top;
} else {
q->next = eshot->next;
eshot->next = eshot_free;
eshot_free = eshot;
eshot = q->next;
}
}else{
q = eshot;
eshot = eshot->next;
}
}
eshot_erase--;
}
}
/*
* 敵弾消滅
*/
#if 0
ESHOT *EraseEShot( ESHOT *eshot )
{
ESHOT *next;
next = eshot->next;
eshot->type = 0;
/* 使っているリストから抜く */
if ( eshot->pre ) {
eshot->pre->next = eshot->next;
if ( eshot->next ) eshot->next->pre = eshot->pre;
} else {
if ( eshot->next ) eshot->next->pre = 0;
eshot_top = eshot->next;
}
/* 空いているリストに入れる */
eshot->pre = 0;
eshot->next = eshot_free;
eshot_free = eshot;
return next;
}
#endif
static void InitEShotEng01( ESHOT *eshot )
{
eshot->pt = eng1_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &eng1_pt[0];
eshot->hit_p = eng1_p_hit;
eshot->hit_o = eng1_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotEng02( ESHOT *eshot )
{
eshot->pt = eng2_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &eng2_pt[0];
eshot->hit_p = eng2_p_hit;
eshot->hit_o = eng2_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotEng03( ESHOT *eshot )
{
eshot->pt = eng3_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &eng3_pt[0];
eshot->hit_p = eng3_p_hit;
eshot->hit_o = eng3_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotNomal( ESHOT *eshot )
{
eshot->pt = nomal_pt[0]+pt_rot[eshot->angle];
eshot->info = 0x0300|PRIORITY_ESHOT|info_rot[eshot->angle];
eshot->pt_ = &nomal_pt[0];
eshot->hit_p = nomal_p_hit;
eshot->hit_o = nomal_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotSyuriken( ESHOT *eshot )
{
eshot->pt = syuriken_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &syuriken_pt[0];
eshot->hit_p = syuriken_p_hit;
eshot->hit_o = syuriken_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotEnergy01( ESHOT *eshot )
{
eshot->pt = energy1_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &energy1_pt[0];
eshot->hit_p = energy1_p_hit;
eshot->hit_o = energy1_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotEnergy02( ESHOT *eshot )
{
eshot->pt = energy2_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &energy2_pt[0];
eshot->hit_p = energy2_p_hit;
eshot->hit_o = energy2_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotEnergy03( ESHOT *eshot )
{
eshot->pt = energy3_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &energy3_pt[0];
eshot->hit_p = energy3_p_hit;
eshot->hit_o = energy3_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotRing01( ESHOT *eshot )
{
eshot->pt = ring1_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &ring1_pt[0];
eshot->hit_p = ring1_p_hit;
eshot->hit_o = ring1_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotRing02( ESHOT *eshot )
{
eshot->pt = ring2_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = &ring2_pt[0];
eshot->hit_p = ring2_p_hit;
eshot->hit_o = ring2_o_hit;
eshot->func_eshot_move = MoveShot1;
eshot->laser=0;
return;
}
static void InitEShotLaser00( ESHOT *eshot )
{
eshot->pt = laser00_pt[0]+pt_rot[eshot->angle];
eshot->info = 0x0300|PRIORITY_ESHOT|info_rot[eshot->angle];
eshot->pt_ = &laser00_pt[0];
eshot->hit_p = laser00_p_hit;
eshot->hit_o = laser00_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotCutter( ESHOT *eshot )
{
eshot->pt = cutter_pt[0]+pt_rot[eshot->angle];
eshot->info = 0x0300|PRIORITY_ESHOT|info_rot[eshot->angle];
eshot->pt_ = &cutter_pt[0];
eshot->hit_p = cutter_p_hit;
eshot->hit_o = cutter_o_hit;
eshot->func_eshot_move = MoveShot2;
eshot->laser=0;
return;
}
static void InitEShotHoming( ESHOT *eshot )
{
eshot->pt = homing_pt[0]+pt_rot[eshot->angle];
eshot->info = 0x0300|PRIORITY_ESHOT|info_rot[eshot->angle];
eshot->pt_ = &homing_pt[0];
eshot->hit_p = homing_p_hit;
eshot->hit_o = homing_o_hit;
eshot->func_eshot_move = MoveShot3;
eshot->laser=0;
return;
}
static void InitEShotParachute( ESHOT *eshot )
{
static unsigned char seed=0;
eshot->pt = parachute_pt[0]+pt_rot[eshot->angle];
eshot->info = 0x0900|PRIORITY_ESHOT;
eshot->pt_ = ¶chute_pt[0];
eshot->hit_p = parachute_p_hit;
eshot->hit_o = parachute_o_hit;
eshot->func_eshot_move = MoveShot4;
eshot->laser=0;
eshot->angle=128;
if( rndtable[seed++]>128 )
eshot->state=0;
else
eshot->state=1;
seed&=255;
return;
}
static void InitEShotParabola( ESHOT *eshot )
{
eshot->pt = parabola_pt[0];
eshot->info = 0x0300|PRIORITY_ESHOT;
eshot->pt_ = ¶bola_pt[0];
eshot->hit_p = parabola_p_hit;
eshot->hit_o = parabola_o_hit;
eshot->func_eshot_move = MoveShot5;
eshot->laser=0;
return;
}
static void InitEShotLaser01( ESHOT *eshot )
{
eshot->laser=1;
eshot->box.x1=eshot->box.x2=eshot->old_box.x1=eshot->old_box.x2 = eshot->enemy->x;
eshot->box.y1=eshot->box.y2=eshot->old_box.y1=eshot->old_box.y2 = eshot->enemy->y;
eshot->box.color = 0xFF;
eshot->old_box.color = 0;
eshot->hit_p = laser01_p_hit;
eshot->hit_o = laser01_o_hit;
eshot->func_eshot_move = MoveShot6;
return;
}
static void InitEShotLaserEX( ESHOT *eshot )
{
eshot->laser=1;
eshot->box.x1=eshot->box.x2=eshot->old_box.x1=eshot->old_box.x2 = eshot->enemy->x;
eshot->box.y1=eshot->box.y2=eshot->old_box.y1=eshot->old_box.y2 = eshot->enemy->y;
eshot->box.color = 0xFF;
eshot->old_box.color = 0;
eshot->hit_p = laserex_p_hit;
eshot->hit_o = laserex_o_hit;
eshot->func_eshot_move = MoveShot7;
return;
}
/* アニメーションする */
static short MoveShot1( ESHOT *es )
{
short es_x,es_y,pt;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
es_x = ((es->lx += es->vx) >> 16);
es_y = ((es->ly += es->vy) >> 16);
es->x = es_x-8; /*-8は表示位置をずらすため*/
es->y = es_y-8;
if(((unsigned short) es_x > 256 + 16) || ((unsigned short) es_y > 256 + 16)
|| (CheckBGHit(es_x-16,es_y-16)!=NON_BG) )
return 0;
pt=es->pt_[(es->anim_count++)/4];
if( pt == -1 ){
pt=es->pt_[0];
es->anim_count=0;
}
es->pt = pt;
xsp_set_st( es );
return 1;
}
/* アニメーションしない */
static short MoveShot2( ESHOT *eshot )
{
short es_x,es_y;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
es_x = ((eshot->lx += eshot->vx) >> 16);
es_y = ((eshot->ly += eshot->vy) >> 16);
eshot->x = es_x-8; /*-8は表示位置をずらすため*/
eshot->y = es_y-8;
if(((unsigned short) es_x > 256 + 16) || ((unsigned short) es_y > 256 + 16)
|| (CheckBGHit(es_x-16,es_y-16)!=NON_BG) )
return 0;
xsp_set_st( eshot );
return 1;
}
#if 0
static short MoveShot2_B( ESHOT *eshot )
{
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
eshot->x = ((eshot->lx += eshot->vx) >> 16);
eshot->y = ((eshot->ly += eshot->vy) >> 16);
if(((unsigned short) eshot->x > 256 + 16) || ((unsigned short) eshot->y > 256 + 16)
|| (CheckBGHit(eshot->x-16,eshot->y-16)!=NON_BG) )
return 0;
xobj_set_st( eshot );
return 1;
}
#endif
/* ホーミング */
short MoveShot3( ESHOT *es )
{
short es_x,es_y,tmp,anim_num,num,pt[2]={0,9};
short pl_x=player[0].x,pl_y=player[0].y;
HIT_XY *hit_p=homing_p_hit;
HIT_XY *hit_o=homing_o_hit;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
es_x = ((es->lx += es->vx) >> 16);
es_y = ((es->ly += es->vy) >> 16);
es->x = es_x-8; /*-8は表示位置をずらすため*/
es->y = es_y-8;
if( (anim_num=((es->anim_count++)/4)) > 1 ){
es->anim_count=0;
anim_num=0;
}
es->pt = homing_pt[0]+(num=pt_rot[es->angle])+pt[anim_num];
es->info = (es->info & 0x0FFF) | info_rot[es->angle];
es->hit_p=&hit_p[num];es->hit_o=&hit_o[num];
if( es->count++ > 4 && es->state < 32 ) { /* 4 回移動するごとに向き修正、32 回追いかけたら終わり */
tmp = calc_direction(es_x, es_y, pl_x, pl_y);
tmp = (tmp - es->angle) & (256 - 1);
if( tmp ) {
if (tmp > 127) es->angle-=8 ;
else es->angle+=8 ;
es->angle &= 256 - 1;
}
es->vx = vx_tbl[es->speed][es->angle];
es->vy = vy_tbl[es->speed][es->angle];
es->state++;
es->count=0;
}else{
if(((unsigned short) es_x > 256 + 16) || ((unsigned short) es_y > 256 + 16)
|| (CheckBGHit(es_x-16,es_y-16)!=NON_BG) )
return 0;
}
xsp_set_st( es );
return 1;
}
/* 落下傘 */
short MoveShot4( ESHOT *es )
{
short anim_pt=0;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
es->x = ((es->lx += es->vx) >> 16);
es->y = ((es->ly += es->vy) >> 16);
if( es->vy > 65536/4 ){ /* 下向き */
if( !es->state ){
if( ++es->angle>128+32 ){
es->angle=128+32;
es->state=1;
}
}else{
if( --es->angle<128-32 ){
es->angle=128-32;
es->state=0;
}
}
if( es->anim_count++ > 4 ){
anim_pt=9;
if( es->anim_count > 8 )
es->anim_count=0;
}
es->pt = obj_shot_b+15 + ((es->angle-96) >> 3)+anim_pt;
es->vx=vx_tbl[8][es->angle];
if(((unsigned short) es->x > 256 + 16) || ((unsigned short) es->y > 256 + 16)
|| (CheckBGHit(es->x-16,es->y-16)!=NON_BG) )
return 0;
xobj_set_st( es );
}else{ /* 上向き */
es->vy += 4096;
es->x -= 8; /*-8は表示位置をずらすため*/
es->y -= 8;
if( es->anim_count++ > 4 ){
anim_pt=1;
if( es->anim_count > 8 )
es->anim_count=0;
}
es->pt = obj_shot+0x70+anim_pt;
xsp_set_st( es );
}
return 1;
}
/* 放物線 */
short MoveShot5( ESHOT *es )
{
short es_x,es_y;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
es_x = ((es->lx += es->vx) >> 16);
es_y = ((es->ly += es->vy) >> 16);
es->x = es_x-8; /*-8は表示位置をずらすため*/
es->y = es_y-8;
if(((unsigned short) es_x > 256 + 16) || ((unsigned short) es_y > 256 + 16)
|| (CheckBGHit(es_x-16,es_y-16)!=NON_BG) )
return 0;
if( (es->vy += 4096) > 2*65536 )
es->vy = 2*65536;
xsp_set_st( es );
return 1;
}
/* 横レーザー */
short MoveShot6( ESHOT *es )
{
extern BOX_PTR *old_box_buf[32],*box_buf[32];
extern short old_box_num,box_num;
signed short t;
es->old_box.x1=es->box.x1;
es->old_box.y1=es->box.y1;
es->old_box.x2=es->box.x2;
es->old_box.y2=es->box.y2;
if( es->box.x1 >= 0 ){ /* レーザーの端が画面外に出るまで伸びる */
es->box.x2=es->enemy->x+es->box_x;
es->box.x1-=4;
if( es->box.x1>es->box.x2 )es->box.x1=es->box.x2-4;
}else{
es->box.x1-=4;
es->box.x2-=4;
}
es->x=(es->box.x1+es->box.x2)/2;
es->hit_p->x=(t=es->x-es->box.x1)+PLAYER_HIT_X;
es->hit_o->x=t+OPTION_HIT_X;
es->box.y1=es->box.y2=es->y=es->enemy->y+es->box_y;
es->hit_p->y=1+PLAYER_HIT_Y;
es->hit_o->y=1+OPTION_HIT_Y;
es->lx=(es->x+16) << 16;
es->ly=(es->y+16) << 16;
old_box_buf[old_box_num++]=&es->old_box;
old_box_num&=31;
old_box_buf[old_box_num]=(BOX_PTR *)0;
if( es->box.x2 < 0 || es->box.x1 > 255 )
return 0;
box_buf[box_num++]=&es->box;
box_num&=31;
box_buf[box_num]=(BOX_PTR *)0;
return 1;
}
/* あとから太くなる横レーザー */
short MoveShot7( ESHOT *es )
{
extern BOX_PTR *old_box_buf[32],*box_buf[32];
extern short old_box_num,box_num;
signed short t;
es->old_box.x1=es->box.x1;
es->old_box.y1=es->box.y1;
es->old_box.x2=es->box.x2;
es->old_box.y2=es->box.y2;
if( es->box.x1 >= 0 ){ /* レーザーの端が画面外に出るまで伸びる */
es->box.x2=es->enemy->x+es->box_x;
es->box.x1-=2;
if( es->box.x1>es->box.x2 )es->box.x1=es->box.x2-4;
es->box.y1=es->box.y2=es->y=es->enemy->y+es->box_y;
}else{
if(es->count++<12){
es->box.y1=(es->y=es->enemy->y+es->box_y)-es->count/4;
es->box.y2=(es->y=es->enemy->y+es->box_y)+es->count/4;
}else{
es->box.x1-=2;
es->box.x2-=2;
}
}
es->x=(es->box.x1+es->box.x2)/2;
es->hit_p->x=(t=es->x-es->box.x1)+PLAYER_HIT_X;
es->hit_o->x=t+OPTION_HIT_X;
es->hit_p->y=1+PLAYER_HIT_Y;
es->hit_o->y=1+OPTION_HIT_Y;
es->lx=(es->x+16) << 16;
es->ly=(es->y+16) << 16;
/*printf("x1=%d x2=%d x=%d hx=%d \n",es->box.x1,es->box.x2,es->x,es->hit_px);*/
old_box_buf[old_box_num++]=&es->old_box;
old_box_num&=31;
old_box_buf[old_box_num]=(BOX_PTR *)0;
if( es->box.x2 < 0 || es->box.x1 > 255 ){
return 0;
}
box_buf[box_num++]=&es->box;
box_num&=31;
box_buf[box_num]=(BOX_PTR *)0;
return 1;
}